//
//  ViewController.m
//  06-NavigationController
//
//  Created by Snow on 16/7/21.
//  Copyright © 2016年 Snow. All rights reserved.
//

#import "ViewController.h"
#import "PushViewController.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //设置navigation的属性
    //1.设置标题 两种方式
    self.title = @"QAQ";
    self.navigationItem.title = @"...";
    //2.titleView 标题视图
    UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:@[@"韩旭", @"王煌"]];
    segment.frame = CGRectMake(0, 0, 150, 40);
    //修改视图的x,y 对视图本身位置没有影响
    self.navigationItem.titleView = segment;
    //3.左
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(comeBack:)];
    //4.右
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(add:)];
    //5.数组
    //6.rightBarButtonItems 数组
    //barButtonItems 数组中放1-2个item为最优
    //7.隐藏navigationBar yes 隐藏 默认为No
//    self.navigationController.navigationBarHidden = YES;
//    self.navigationController.navigationBar.hidden = YES;
    //8.navigationBar 背景样式 默认为default
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    //9.navigationBar的背景颜色 里面
    self.navigationController.navigationBar.backgroundColor = [UIColor redColor];
    //10.barTintColor Bar的颜色 表面
    self.navigationController.navigationBar.barTintColor = [UIColor cyanColor];
    //11.tintColor Bar上元素的颜色
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    //12.translucent 管理半透明效果 yes为开启 no为关闭
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(0, 0, 200, 200);
    button.backgroundColor = [UIColor blueColor];
    [self.view addSubview:button];
    [button addTarget:self action:@selector(handleButton:) forControlEvents:UIControlEventTouchUpInside];
    //设置为yes时,self.view坐标系从原点开始
    //设置为no时.坐标系从navigationBar开始
    self.navigationController.navigationBar.translucent = NO;
    //13.改变坐标效果 与透明度为No时效果一样
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.view.frame = CGRectMake(0, -64, 414, 700);
    //14. 页面跳转
    //push
    //pop
    //获取到navigationContrller所有的控制器
//    self.navigationController.viewControllers
    //topViewCOntroller 栈顶视图控制器
    //visibleViewController 可见视图控制器
    
}
- (void)handleButton:(UIButton *)button
{
    //将视图控制器入栈
    [self.navigationController pushViewController:[[PushViewController alloc] init] animated:YES];

}
- (void)comeBack:(UIBarButtonItem *)barButtonItem
{

}
- (void)add:(UIBarButtonItem *)barButtonItem
{
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
